<template>
  <div class="body">
    <div class="container">
      <div class="box-left">
        <div class="logo">
          <img src="../../public/images/logo1.svg" alt="" />
        </div>
        <div class="wrapper">
          <swiper :options="swiperOption">
            <swiper-slide>
              <div
                class="swiper-item"
                style="
                  background-image: url(https://account.djicdn.com/pc/static/img/2.643c4c1.jpg);
                "
              ></div>
            </swiper-slide>
            <swiper-slide>
              <div
                class="swiper-item"
                style="
                  background-image: url(https://account.djicdn.com/pc/static/img/1.e61fc72.jpg);
                "
              ></div>
            </swiper-slide>
            <swiper-slide>
              <div
                class="swiper-item"
                style="
                  background-image: url(https://account.djicdn.com/pc/static/img/3.61f61fa.jpg);
                "
              ></div>
            </swiper-slide>

            <!-- Optional controls -->
            <div class="swiper-pagination" slot="pagination"></div>
          </swiper>
        </div>
      </div>
      <div class="box-right">
        <div class="login">
          <header>登录</header>
          <div class="choose">
            <p @click="isShow = true" :class="{ 'choose-active': isShow }">
              账号登录
            </p>
            <h5></h5>
            <p @click="isShow = false" :class="{ 'choose-active': !isShow }">
              扫码登录
            </p>
          </div>
          <!-- 显示输入框 -->
          <div class="ipt" v-if="isShow">
            <el-input
              v-model="phoneNum"
              placeholder="请输入电话号码"
              clearable
              :class="{ iptsty: true }"
            ></el-input>
            <el-input
              v-model="password"
              placeholder="请输入点密码"
              clearable
              show-password
              maxlength="16"
              minlength="8"
              :class="{ iptsty: true }"
            ></el-input>
            <div class="btn">
              <el-button
                type="primary"
                :class="{ btnsty: true }"
                @click.native="clickToLogin"
                >登录</el-button
              >
            </div>

            <div class="zhuche">
              <a href=""> 手机短信登录/注册</a> <a href="">注册DJI账号</a>
            </div>
            <div class="other">
              <p>或使用第三方登录</p>
            </div>
            <div class="btn">
              <el-button type="success" :class="{ btnsty: true }">
                <i class="iconfont">&#xe7e5;</i>微信
              </el-button>
            </div>
            <h1>
              若继续，则表示同意 隐私政策 和 使用条款，DJI
              会收集您的第三方登录信息进行账号注册或登录。
            </h1>
            <div class="wenti">
              <a href=""> 联系客服</a>
              <h5></h5>
              <a href=""> 常见问题</a>
            </div>
          </div>
          <!-- 显示二维码 -->
          <div class="qrcode" v-if="!isShow">
            <img src="../assets/picpath/111.jpg" alt="" />
            <p>使用微信扫一扫</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { userLogin } from "@/assets/tool/request.js";
import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";
import "swiper/css/swiper.css";
export default {
  data() {
    return {
      phoneNum: "18011111111",
      password: "qwertyui",
      isShow: true,
      swiperOption: {
        effect: "fade",
        pagination: {
          el: ".swiper-pagination",
          bulletActiveClass: "my-bullet-active",
        },
        /* 是否循环 */
        loop: true,
        speed: 3000,
        autoplay: {
          /* 触碰后自动切换是否停止 */
          disableOnInteraction: false,
          delay: 0,
        },
      },
    };
  },
  components: {
    Swiper,
    SwiperSlide,
  },
  directives: {
    swiper: directive,
  },
  methods: {
    // 登录
    async clickToLogin() {
      let res = await userLogin({
        phone: this.phoneNum,
        password: this.password,
      });
      this.$store.commit("gettoken", res.data.result.token);
      sessionStorage.setItem("token", res.data.result.token);
      this.$store.dispatch('user/login',this.phoneNum)
      if (Object.keys(this.$route.query).length == 0) {
        this.$router.push("/index");
      } else {
        this.$router.push(this.$route.query.redirect);
      }

    },
  },
};
</script>

<style lang="scss" scoped>
@import "../assets/styles/iconfont.css";
.body {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgb(238, 238, 238);
  .container {
    width: 1100px;
    height: 850px;
    display: flex;
    background-color: #fff;
    .box-left {
      position: relative;
      flex: 1;
      // background-color: pink;
      overflow: hidden;
      .logo {
        position: absolute;
        left: 20px;
        top: 20px;
        width: 80px;
        height: 80px;
        z-index: 21;
      }
      .swiper-item {
        width: 550px;
        height: 850px;
      }
      .swiper-button-next,
      .swiper-button-prev {
        color: #fff;
      }
      .swiper-item {
        background-size: cover;
        background-position: center;
      }
    }
    .box-right {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      .login {
        width: 300px;
        header {
          font-size: 30px;
          line-height: 45px;
          text-align: center;
        }
        .ipt {
          height: 400px;
        }
        .choose {
          margin-top: 10px;
          display: flex;
          font-size: 18px;
          line-height: 25px;
          justify-content: space-around;
          align-items: center;
          h5 {
            width: 1px;
            height: 18px;
            background-color: #ccc;
          }
          P:hover {
            cursor: pointer;
          }
        }
        .btn {
          width: 100%;
          margin-top: 15px;
        }
        .zhuche,
        .wenti {
          display: flex;
          justify-content: space-between;
          font-size: 16px;
          line-height: 24px;
          margin-top: 15px;
          a {
            color: rgb(68, 168, 242) ；;
          }
        }
        .other {
          margin-top: 15px;
          display: flex;
          justify-content: center;
          align-items: center;
          &::after,
          &::before {
            content: "";
            height: 1px;
            width: 60px;
            background-color: #eee;
          }
          p {
            font-size: 16px;
            line-height: 40px;
            color: rgb(112, 116, 115);
            padding: 0 10px;
          }
        }
        h1 {
          font-size: 12px;
          line-height: 18px;
          color: rgb(112, 116, 115);
          text-align: center;
          margin-top: 10px;
        }
        .wenti {
          justify-content: center;
          align-items: center;
          a {
            margin: 0 10px;
          }
          h5 {
            width: 1px;
            height: 18px;
            background-color: #ccc;
          }
        }
        .qrcode {
          height: 400px;
          text-align: center;
          // line-height: 300px;
          img {
            width: 200px;
            height: 200px;
            border: 3px solid #ccc;
            margin-top: 50px;
          }
          p {
            margin-top: 20px;
            font-size: 14px;
          }
        }
      }
    }
  }
}

.iptsty {
  margin-top: 15px;
}
.btnsty {
  width: 100%;
  height: 40px;
  font-size: 18px;
  font-weight: 500;
}
.iconfont {
  font-size: 20px !important;
  margin-right: 10px;
}

.choose-active {
  color: rgb(68, 168, 242);
}
</style>

<style>
.my-bullet-active {
  background: #fff;
  opacity: 0.6;
  transition: all 0.2s;
}
</style>